from PyQt5.QtWidgets import QApplication, QTableWidget
from pgtools.plugins.client.qtwidget_helper import TTableWidget

user_cols= ('number', 'password', 'name', 'rank','dep', 'online', 'role')
user_data=[('1000', '1000', 'admin', '中士', 1, 0, 'admin'),
            ('1001', '1001', '王一', '下士', 8, 0, 'user'),
            ('1002', '1002','王二', '义务兵', 11, 0, 'user'),
            ('1003', '1003', '王三', '义务兵', 12, 0, 'user'),
            ('1004', '1004', '王四', '下士', 10, 0, 'user'),
            ('1005', '1005', '王五', '中尉', 7, 0, 'user'),
            ('1006', '1006', '李一', '下士', 9, 0, 'user'),
            ]


app = QApplication([])
t = QTableWidget()
t.setWindowTitle("表格示例")
t_table = TTableWidget(t, 7, 7, user_data, user_cols, True)
t.resize(1100, 600)

def remove_row():
    cur = t_table.get_current_row()
    t_table.delete_row(cur)
    
menu_data ={
    '删除行': remove_row
}

t_table.set_menu_data(menu_data, '菜单' )
t.show()
app.exec_()